import api from "../../utils/api_util";
import baseUtil from "../../utils/base_util";

var WxParse = require('../../wxParse/wxParse.js');

const app = getApp();
Page({
    data: {
        StatusBar: app.globalData.StatusBar,
        CustomBar: app.globalData.CustomBar,
        detailData: '',
        time: '',
        jumpType:'',
    },

    onShow: function () {


        if (baseUtil.getCurrentUrlParam('type') && baseUtil.getCurrentUrlParam('type') == 'msg') {

            this.getMsgDetail();
        } else {

            this.getPublicMsg();
        }

        this.setData({
            jumpType:baseUtil.getCurrentUrlParam('type'),
        })
    },

    //公告
    getPublicMsg: function () {
        let that = this;
        api.wxRequest.apiRequest(that, api.urls.informationDetail, {
            method: 'GET',
            data: {
                id: baseUtil.getCurrentUrlParam('id')
            },
            success: function (res) {
                WxParse.wxParse('noticeDetail', 'html', res.data.content, that, 5);
                let time = baseUtil.formatDateTime(res.data.createTime);
                console.log(time)
                that.setData({
                    detailData: res.data,
                    time: time,
                })
            },
        })
    },

    //消息详情
    getMsgDetail: function () {
        let that = this;
        api.wxRequest.apiRequest(that, api.urls.msgDetail, {
            method: 'GET',
            data: {
                v: '1.0.0',
                oid: baseUtil.getCurrentUrlParam('id'),
            },
            success: function (res) {
                let time = baseUtil.formatDateTime(res.data.createTime);
                res.data.title ="我的消息"
                console.log(time)
                that.setData({
                    detailData: res.data,
                    time: time,
                })
            },
        })
    },
})